package com.mumu.muPictureBackend.Controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.mumu.muPictureBackend.common.BaseResponse;
import com.mumu.muPictureBackend.common.ResultUtils;
import com.mumu.muPictureBackend.model.dto.Space.CreateSpaceRequest;
import com.mumu.muPictureBackend.model.dto.Space.DeleteSpaceRequest;
import com.mumu.muPictureBackend.model.dto.Space.SpacePageRequest;
import com.mumu.muPictureBackend.model.dto.Space.UpdateSpaceRequest;
import com.mumu.muPictureBackend.model.entity.Space;
import com.mumu.muPictureBackend.service.SpaceService;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
@RequestMapping("/space")
public class SpaceController {
    @Resource
    SpaceService serviceService;

    @PostMapping("/add")
    public BaseResponse<Long> addSpace(@RequestBody CreateSpaceRequest createSpaceRequest, HttpServletRequest httpServletRequest) {
        return ResultUtils.success(serviceService.createSpace(createSpaceRequest, httpServletRequest));
    }

    @PostMapping("/list/page")
    public BaseResponse<Page<Space>> getSpaceList(@RequestBody SpacePageRequest spacePageRequest, HttpServletRequest httpServletRequest) {
        return ResultUtils.success(serviceService.getSpaceList(spacePageRequest, httpServletRequest));
    }

    @PostMapping("/delete")
    public BaseResponse<Boolean> getSpaceList(
            @RequestBody DeleteSpaceRequest deleteSpaceRequest,
            HttpServletRequest httpServletRequest) {
        return ResultUtils.success(serviceService.deleteSpace(deleteSpaceRequest, httpServletRequest));
    }


    @PostMapping("/update")
    public BaseResponse<Boolean> getSpaceList(
            @RequestBody UpdateSpaceRequest updateSpaceRequest,
            HttpServletRequest httpServletRequest) {
        return ResultUtils.success(serviceService.updateSpace(updateSpaceRequest, httpServletRequest));
    }

}
